home *** CD-ROM | disk | FTP | other *** search
- <?xml version="1.0"?>
-
- <!DOCTYPE window SYSTEM "chrome://isreaditlater/locale/isreaditlater.dtd">
-
- <?xml-stylesheet href="chrome://global/skin/global.css" type="text/css"?>
- <?xml-stylesheet href="chrome://isreaditlater/skin/ril.css" type="text/css"?>
-
-
-
-
- <dialog id="RIL_offlineAction"
- xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
- title="Loading..."
- buttons="cancel"
- ondialogaccept="return canCancel();"
- ondialogcancel="return canCancel();"
- onload="setTimeout(perform,333)"
- persist="screenX screenY">
-
-
- <label>Depending on how many files you have, this might take a while.</label>
- <progressmeter mode="undetermined"/>
-
-
- <stringbundleset id="stringbundleset">
- <stringbundle id="isRitL-strings" src="chrome://isreaditlater/locale/jsstrings.properties"/>
- </stringbundleset>
-
- <script type="application/x-javascript">
- var thread, action, newFolder;
- var APP, ASSETS;
-
- function perform()
- {
- action = window.arguments[0];
-
- APP = Components.classes['@ril.ideashower.com/rildelegate;1'].getService().wrappedJSObject;
- ASSETS = Components.classes['@ril.ideashower.com/rilassetmanager;1'].createInstance(Components.interfaces.nsIRILassetManager);
- ASSETS.init();
-
- if ( APP.OFFLINE.clearingOffline || APP.OFFLINE.movingOffline )
- {
- // not allowed to do more than one at a time
- return window.close();
- }
-
- switch(action)
- {
- case('clearing'):
- title = 'Clearing Offline Files...';
- clearOffline();
- break;
- case('moving'):
- title = 'Moving Offline Files...';
- moveOffline();
- break;
- default:
- return window.close();
- break;
- }
-
- document.getElementById('RIL_offlineAction').setAttribute('title', title);
- }
-
-
- function clearOffline()
- {
- // stop the queue if it is running
- APP.OFFLINE.cancel();
-
- // Clear
- APP.OFFLINE.setOfflineStatus('clearing', true);
-
- APP.LIST.resetOffline();
- clearThread.DIR_PAGES = ASSETS.DIR_PAGES;
- clearThread.DIR_ASSETS = ASSETS.DIR_ASSETS;
-
- thread = Components.classes["@mozilla.org/thread-manager;1"].getService().newThread(0);
- thread.dispatch(clearThread, thread.DISPATCH_NORMAL);
-
- }
-
-
- function moveOffline()
- {
- APP.OFFLINE.setOfflineStatus('moving', true);
-
- let close = false;
- newFolder = movingThread.newFolder = window.arguments[1];
-
- let newPathPages = newFolder.path + ASSETS.FD + ASSETS.PAGES_FOLDER_NAME;
- let newPathAssets = newFolder.path + ASSETS.FD + ASSETS.ASSETS_FOLDER_NAME;
- let newPages = APP.ASSETS.file(newPathPages);
- let newAssets = APP.ASSETS.file(newPathAssets);
-
- if (!newPages.exists())
- {
- if (!newAssets.exists())
- {
- let thread = Components.classes["@mozilla.org/thread-manager;1"].getService().newThread(0);
- thread.dispatch(movingThread, thread.DISPATCH_NORMAL);
- }
- }
- else
- {
- // if they do already contain asset folders, flush offline settings of all items (and rebuild by scanning)
- APP.LIST.resetOffline();
-
- // #beta2 start scanning new folder in a thread for files #beta (also update downloader to check for web.html and text.html)
-
- APP.OFFLINE.setOfflineStatus('moving', false);
-
- // set new directory
- APP.PREFS.set('offlinePath', newFolder.path);
-
- if (close) window.close();
- }
-
- }
-
- function canCancel()
- {
- try {
- thread.shutdown();
- } catch(e) {
- Components.utils.reportError(e);
- }
-
- return true;
- }
-
- clearThread = {
-
- run : function()
- {
- try {
-
- try {
- this.DIR_PAGES.remove(true);
- this.DIR_ASSETS.remove(true);
- } catch(e) {Components.utils.reportError(e);}
-
- var main = Components.classes["@mozilla.org/thread-manager;1"].getService().mainThread;
- main.dispatch(new mainThread(), this.DISPATCH_NORMAL);
-
- } catch(e) {Components.utils.reportError(e);}
- },
-
- QueryInterface: function(iid)
- {
- if (iid.equals(Components.interfaces.nsIRunnable) ||
- iid.equals(Components.interfaces.nsISupports)) {
- return this;
- }
- throw Components.results.NS_ERROR_NO_INTERFACE;
- }
-
- }
-
- movingThread = {
-
- run : function()
- {
- try {
- let ASSETS = Components.classes['@ril.ideashower.com/rilassetmanager;1'].createInstance(Components.interfaces.nsIRILassetManager);
- ASSETS.init();
-
- try {
- ASSETS.DIR_PAGES.moveTo( this.newFolder, null );
- ASSETS.DIR_ASSETS.moveTo( this.newFolder, null );
- } catch(e) {Components.utils.reportError(e);}
-
- var main = Components.classes["@mozilla.org/thread-manager;1"].getService().mainThread;
- main.dispatch(new mainThread(), this.DISPATCH_NORMAL);
-
- } catch(e) {Components.utils.reportError(e);}
- },
-
- QueryInterface: function(iid)
- {
- if (iid.equals(Components.interfaces.nsIRunnable) ||
- iid.equals(Components.interfaces.nsISupports)) {
- return this;
- }
- throw Components.results.NS_ERROR_NO_INTERFACE;
- }
-
- }
-
- function mainThread() {}
- mainThread.prototype = {
-
- run: function()
- {
- if (action == 'moving')
- APP.PREFS.set('offlinePath', newFolder.path);
-
- APP.OFFLINE.setOfflineStatus(action, false);
-
- window.close();
- },
-
- QueryInterface: function(iid) {
- if (iid.equals(Components.interfaces.nsIRunnable) ||
- iid.equals(Components.interfaces.nsISupports)) {
- return this;
- }
- throw Components.results.NS_ERROR_NO_INTERFACE;
- }
-
- }
-
-
- </script>
-
- </dialog>
-